<template>
  <div class="detail">
    <div class="login-panel">
      <div class="left">
        <img :src="generateImgUrl(userInfo.photoUrl)" mode="aspectFill" />
      </div>
      <div class="right">
        <div class="name">{{ userInfo.realName }}</div>
        <div class="tags">
          <div class="tag" v-if="userInfo.certificate">已实名</div>
          <div class="tag dark" v-else @click="handleFace">未实名</div>
          <div class="tag" v-if="userInfo.npcmember">人大代表</div>
        </div>
      </div>
    </div>
    <div class="ele-info">
      <div class="item">
        <div class="title">代表编号</div>
        <div class="text">{{ data.number }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">人大届别</div>
        <div class="text">{{ data.periodName }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">所属选区</div>
        <div class="text">{{ data.eleName }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">代表级别</div>
        <div class="text">{{ data.level }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">任职类型</div>
        <div class="text">{{ data.type }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">任职日期</div>
        <div class="text">{{ data.takeOfficeTime }}</div>
      </div>
    </div>
    <div class="user-info">
      <div class="item">
        <div class="title">姓名</div>
        <div class="text">{{ data.name }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">性别</div>
        <div class="text">{{ data.sex === '' ? '' : data.sex === '1' ? '男' : '女' }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">民族</div>
        <div class="text">{{ data.nation }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">出生日期</div>
        <div class="text">{{ data.birthday }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">籍贯</div>
        <div class="text">{{ data.place }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">党派</div>
        <div class="text">{{ data.political }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">学历</div>
        <div class="text">{{ data.education }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">职业构成</div>
        <div class="text">{{ data.occupationalStructure }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">行业构成</div>
        <div class="text">{{ data.industryStructure }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">身份证号码</div>
        <div class="text">{{ data.certNo }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">参加工作时间</div>
        <div class="text">{{ data.startWorkDate }}</div>
      </div>
      <div class="line"></div>
      <div class="item">
        <div class="title">现任/原任职务</div>
        <div class="text">{{ data.job }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import api from '@/api'
import { generateImgUrl } from '@/utils'

export default {
  data () {
    return {
      generateImgUrl,
      data: {},
    }
  },
  computed: {
    userInfo () {
      return this.$store.state.userInfo
    },
  },
  onLoad () {
    this.getUserInfo()
  },
  methods: {
    async getUserInfo () {
      const { result } = await api.getUserInfo()
      this.data = result
    },
  },
}
</script>

<style lang="scss" scoped>
@import "~css/var.scss";

.detail {

  .login-panel {
    display: flex;
    align-items: center;
    width: 100%;
    height: 104px;
    margin: 0 auto;
    background: #fff;

  .left {
    width: 70px;
    height: 70px;
    margin-left: 20px;

    img {
      width: 100%;
      height: 100%;
      border-radius: 50%;
    }
  }

  .right {
    margin-left: 20px;

    .name {
      line-height: 24px;
      font-weight: bold;
      font-size: $fz-l;
      color: #333;
    }

    .tags {
      display: flex;
      margin-top: 18px;

      .tag {
        margin-right: 8px;
        padding: 0;
        padding: 0 10px;
        border: 1px solid #e51e1e;
        border-radius: 3px;
        line-height: 21px;
        font-size: $fz-s;
        color: #fff;
        background: #e51e1e;

        &.dark {
          border: 1px solid #e51e1e;
          color: #e51e1e;
          background: #fff;
          }
        }
      }
    }
  }

  .ele-info, .user-info {
    background-color: #fff;
    margin-top: 10px;

    .item {
      display: flex;
      align-items: center;
      width: 100%;
      height: 44px;

      .title {
        width: 106px;
        line-height: 44px;
        margin-left: 14px;
        font-size: $fz-m;
        color: #999999;
        font-weight: 500;
      }

      .text {
        line-height: 44px;
        font-size: $fz-m;
        color: #333333;
        font-weight: 500;
      }
    }

    .line {
      margin: 0 10px;
      height: 1px;
      background: #f4f2f3;
    }
  }
}
</style>
